﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;


namespace StateManagement
{
    public partial class SessionText : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Add("Texts",new List<string>());
        }

        protected void Button_Click(object sender, EventArgs e)
        {
           ((List<string>)Session["Texts"]).Add(TextBox.Text);
        }
       
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (Session["Texts"] == null)
            {
                Session["Texts"] = "";
            }
            foreach (var item in (List<string>)Session["Texts"])
            {
                Label.Text = Label.Text+item.ToString() + "<br/>";
            }
        }
    }
}